<!-- 测试页 -->
<template>
  <div class="test">
    <button @click="start">开始</button>
    <button @click="end">结束</button>
    <span>{{ time }}</span>
  </div>
</template>

<script>
import { mapState } from "vuex";

export default {
  data() {
    return {};
  },
  mounted() {},
  methods: {
    start() {
      this.$store.dispatch("exam/startExam", 2);
    },
    end() {
      this.$store.dispatch("exam/endExam");
    },
  },
  computed: {
    ...mapState("exam", {
      time: (state) => {
        let date = state.time
        let h = parseInt(date / 3600000)
        date %= 3600000
        let m = parseInt(date / 60000)
        date %= 60000
        let s = parseInt(date / 1000)
        let time = `${h}时${m}分${s}秒`;
        return time;
      },
    }),
  },
};
</script>

<style lang="scss" scoped>
.test {
  min-height: 100vh;
  width: 100%;
}
</style>
